package com.eascs.web.demo.db;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.eascs.common.util.UuidUtil;

@Repository
public class DbDemoDao extends BaseDao {

	public void clean() {
		jdbcSession.execute("delete from users_test");
	}

	public void init() {
		jdbcSession.execute("sql.dbdemodao.init");
	}

	public void add(DbDemoEntity dbDemoEntity) {
		// String sql = "insert into users(id,name,address) values(?,?,?)";
		// jdbcSession.execute(sql, dbDemoEntity.getId(),
		// dbDemoEntity.getName(), dbDemoEntity.getAddress());
		this.jdbcSession.insert(dbDemoEntity);
	}

	public List<DbDemoEntity> list() {
		return jdbcSession.findEntitys("select * from users_test", DbDemoEntity.class);
	}

	public void testTransactional() {
		String sql = "insert into test(id,name) values(?,?)";
		jdbcSession.execute(sql, UuidUtil.generateUuid(), UuidUtil.generateUuid());
	}

}
